<extend name='layout:index'/>
<block name='content'>
<body>
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="tabs-container">
   <ul class="nav nav-tabs text-center">
       <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true" id="a_one" onclick="f1()" style="width: 300px; background-color: white);"><i class="fa fa-lock"></i> 密码变更</a>
       </li>
       <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false" id="a_two" onclick="f2()" style="width: 300px; background-color: white;"><i class="fa fa-shield"></i>安全密码变更</a>
       </li>
   </ul>
   <div class="tab-content">
       <div id="tab-1" class="tab-pane active">
           <div class="panel-body">
           <div class="col-sm-12">
			  <div class="ibox float-e-margins">
			      <div class="ibox-content">
			          <form class="form-horizontal m-t" id="signupForm" action="__MODULE__/person/dopassword" method="post" name="theForm"  novalidate="novalidate" onSubmit="return checkSubmit(this)">
			              <div class="form-group">
			                  <label class="col-sm-3 control-label">*安全密码：</label>
			                  <div class="col-sm-8">
			                      <input id="repassword" name="repassword" class="form-control" type="password">
			                      <span id='empty_password'></span>
			                  </div>
			              </div>
			              <div class="form-group">
			                  <label class="col-sm-3 control-label">*当前密码：</label>
			                  <div class="col-sm-8">
			                      <input id="password" name="password" class="form-control" type="password">
			                  </div>
			              </div>
			              <div class="form-group">
			                  <label class="col-sm-3 control-label">*新密码：</label>
			                  <div class="col-sm-8">
			                      <input id="newpassword" name="newpassword" class="form-control" type="password">
			                  </div>
			              </div>
			              <div class="form-group">
			                  <label class="col-sm-3 control-label">*确认新密码：</label>
			                  <div class="col-sm-8">
			                      <input id="newpassword2" name="newpassword2" class="form-control" type="password">
			                  </div>
			              </div>
			               <div class="form-group">
			                   <div class="col-sm-8 col-sm-offset-3">
			                       <button class="btn btn-primary" type="submit">提交修改</button>
			                   </div>
			               </div>
			           </form>
			       </div>
			   </div>
			</div>
            </div>
        </div>
        <div id="tab-2" class="tab-pane">
            <div class="panel-body">
            <div class="col-sm-12">
			  <div class="ibox float-e-margins">
			    <div class="ibox-content">
            	<form class="form-horizontal m-t" name="aqmmform" action="__MODULE__/person/safeEdit" method="post" onSubmit="return checkSafePassword(this)">
	              <div class="form-group">
	                  <label class="col-sm-3 control-label">*手机验证码：</label>
	                  <div class="col-sm-8">
	                  		<div class="input-group">
                                <input id="mobile_code" name="mobile_code" class="form-control" type="text"> 
                                <span class="input-group-btn"> 
                                	<input id="btnSendCode" class="btn btn-primary" value="获取手机验证码" onclick="sendMessage()" type="button" /> 
                                </span>
                            </div>
	                  </div>
	              </div>
	              <div class="form-group">
	                  <label class="col-sm-3 control-label">*新安全密码：</label>
	                  <div class="col-sm-8">
	                      <input id="repassword1" name="repassword1" class="form-control" type="password">
	                  </div>
	              </div>
	              <div class="form-group">
	                  <label class="col-sm-3 control-label">*确认安全密码：</label>
	                  <div class="col-sm-8">
	                      <input id="repassword2" name="repassword2" class="form-control" type="password">
	                  </div>
	              </div>
	               <div class="form-group">
	                   <div class="col-sm-8 col-sm-offset-3">
	                       <button class="btn btn-primary" type="submit">提交修改</button>
	                   </div>
	               </div>
	           </form>
	           </div>
	           </div>
	           </div>
            </div>
        </div>
   </div>
   </div>
</div>
</div>
<script src="themes/default/js/jquery.min.js?v=2.1.4"></script>
<script src="themes/default/js/bootstrap.min.js?v=3.3.5"></script>
<script src="themes/default/js/content.min.js?v=1.0.0"></script>
<script src="themes/default/js/plugins/validate/jquery.validate.min.js"></script>
<script src="themes/default/js/plugins/validate/messages_zh.min.js"></script>
<script src="themes/default/js/demo/form-validate-demo.min.js"></script>
<script src="themes/default/js/plugins/layer/layer.min.js"></script>

<script>
//下面的是发送手机验证码
var InterValObj; //timer变量，控制时间
var count = 30; //间隔函数，1秒执行
var curCount;//当前剩余秒数

function sendMessage() {
    curCount = count;       
       
    //向后台发送处理数据
         $.ajax({
                    type : 'POST',
                    url : '/home/person/phoneAjax',
                    data : {code:1},
                    dataType : 'html',
                    async : false,
                    success : function(str){                       
                         if(str == '发送成功'){                            
                            //设置button效果，开始计时
                            $("#btnSendCode").attr("disabled", "true");
                            $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
                            InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                        }else{
                               var txt=  "信息错误,请核对后再添";
                               window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.info);
                        }                        
                    }
                
                })
   
}
//timer处理函数
function SetRemainTime() {
    if (curCount == 0) {                
        window.clearInterval(InterValObj);//停止计时器
        $("#btnSendCode").removeAttr("disabled");//启用按钮
        $("#btnSendCode").val("重新发送验证码");
        code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效    
    }
    else {
        curCount--;
        $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
    }
}
    
    // 下面的是验证安全码
  
	function checkSubmit()
	{
 		var k = false;


		if($('#repassword').val() == ''){
			alert('请输入您的安全吗?');
			return false;
		}
		
		if($('#password').val() == ''){
			alert('请输入您的密码');
			return false;
		}
		
		if($('#newpassword').val() == ''){
			alert('请输入您的新密码');
			return false;
		}

        if($('#newpassword2').val() == ''){
			alert('请输入您的新密码');
			return false;
		}		
		 $.ajaxSetup({
             headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
             }
        });
               
         $.ajax({
		            type : 'POST',
		            url : '/home/person/dopassword',
		            data : {repassword:$('#repassword').val(),password:$('#password').val(),newpassword:$('#newpassword').val(),newpassword2:$('#newpassword2').val()},
		            dataType : 'html',
		            async : false,
		            success : function(str){
		                if(str==2){
		                     var txt=  "您 的 安 全 密 码 有 误";
					          window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.info);
					            
		                    return false;
		                }
		                if(str==22){
		                	 var txt=  "您 的 当 前 密 码 有 误";
					          window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.info);
					            
		                    return false;
		                }          
		               if(str==222){
		                	 var txt=  "您 的 两 次 密 码 不 同";
					          window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.info);
					            
		                    return false;
		                }  
		                if(str!=2&&str!=22&&str!=222){
		                	
		                		k = true;
		                }  

		       	 	}
		        
		   	 	})
		   	 	return k;
		   }
  
  		//下面安全码修改
  		function checkSafePassword(){

        if($('#repassword1').val()==' ' || $('#repassword2').val()==''){
            var txt=  "安全码密码未填写";
             window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
             return false;
        }
        if($('#repassword1').val() != $('#repassword2').val()){
        
             var txt=  "两次密码输入不同";
	         window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
	         return false;
        }

         $.ajaxSetup({
             headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
             }
        });
        $.ajax({
            type:'POST',
            data:{repassword1:$('#repassword1').val(),mobile_code:$('#mobile_code').val(),repassword2:$('#repassword2').val()},
            url:'/home/person/editRepassword',
            dataType : 'html',
            async : false,
            success : function(str){
                if(str==1){
                    var txt=  "安全码修改成功";
                    window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.success);
                   return false;
                }
                if(str==22){
                    var txt=  "验证码不正确";
                    window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
                    return false;
                    
                }
                if(str==2){
                    var txt=  "修改失败,请核对信息后再做修改";
                    window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
                    return false;
                }
            }
        })
    return false;
   }
</script>

<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>


</body>
</block>